import {Component} from '@angular/core';
import {IonicPage} from 'ionic-angular';
import {ROUTER} from "../../service/router.service";
import {USER} from "../../service/user.service";
import {UserModel} from "../../model/user.model";
import {GOODS} from "../../api/goods-api";
import {GoodModel} from "../../model/good.model";
import {LocalStorage} from "../../utils/localstorage.utils";

/**
 * Generated class for the IntegralStorePage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-integral-store',
  templateUrl: 'integral-store.html',
})
export class IntegralStorePage {
  user:UserModel;

  commoditys = []

  constructor(public GOODS: GOODS, public USER: USER, public ls:LocalStorage, private ROUTER: ROUTER) {
    this.user = this.USER.get();
  }

  gotoIntegralMall(v) {
    this.ls.setObject('good', new GoodModel(v));
    this.ROUTER.go(ROUTER.INTEGRALMALL, v.id);
  }

  gotoExchangeRecord() {
    this.ROUTER.go(ROUTER.EXCHANGE);
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad IntegralStorePage');
    this.GOODS.getScoreOrderList({type:2,size:999},(v)=>{
      this.commoditys = v.content
    })
  }

}
